#!/bin/bash
#
# Obtiene el numero maximo de leases para la red de
# gestion.
#

if [ "" = "$1" ]
then
   echo "ERROR: Debes indicar la red"
   exit 1
fi

# Obtener el rango
range=$( grep -h range /etc/dhcp/*conf | grep "$1" )

Val1=$(echo "$range" | perl -ne 'print "$1" if($_=~m/range\s+\d+\.\d+\.\d+\.(\d+)\s+/);' )
Val2=$(echo "$range" | perl -ne 'print "$1" if($_=~m/range\s+\S+\s+\d+\.\d+\.\d+\.(\d+)/);' )

Max=$(( $Val2 - $Val1 ))
echo -n "$Max"

